import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'


const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function (location) {
  return originalReplace.call(this, location).catch(err => { })
};
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch(err => { })
};



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [{
      path: '/home/popup',
      component: () => import(/* webpackChunkName: "popup" */ '../views/popup.vue'),
      meta:{
        tabbarShow:false
      }
    }],
    meta:{
      tabbarActiveNum:0,
      tabbarShow:true
    }
  },
  {
    path: '/wode',
    name: 'wode',
    component: () => import(/* webpackChunkName: "wode" */ '../views/wode.vue'),
    meta:{
      tabbarActiveNum:4,
      tabbarShow:true
    }
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import(/* webpackChunkName: "cart" */ '../views/cart.vue'),
    meta:{
      tabbarActiveNum:3,
      tabbarShow:true
    }
   
  },
  {
    path: '/sort',
    name: 'sort',
    component: () => import(/* webpackChunkName: "sort" */ '../views/sort.vue'),
    meta:{
      tabbarActiveNum:2,
      tabbarShow:true
    }
   
  },
  {
    path: '/special',
    name: 'special',
    component: () => import(/* webpackChunkName: "special" */ '../views/special.vue'),
    meta:{
      tabbarActiveNum:1,
      tabbarShow:true
    },
    
   
  },
  {
    path: '/purchase',
    name: 'purchase',
    component: () => import(/* webpackChunkName: "purchase" */ '../views/purchase.vue'),
    meta:{
      tabbarActiveNum:1,
      tabbarShow:false
    },
    
   
  },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})



// 路由守卫
router.beforeEach((to,from,next)=>{

 
  next()
})
export default router
